package com.example.myprojectoffeixue;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.LinearLayout;

public class TextActivity extends Activity {
    MySwitchButton autoButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_text2);
        info();
    }
public void info(){
    autoButton= (MySwitchButton)findViewById(R.id.bt_cl);
    LinearLayout l= (LinearLayout) findViewById(R.id.bt_lin);
    autoButton.setParentView(l);
    autoButton.setOnSwitchStateListener(new OnSwitchListener() {
        @Override
        public void onSwitched(int isSwitchOn) {
            if(isSwitchOn==0){
                Log.d("开","3333333333");
   /* wsc = m.c;
    if (d.size() != 0) {
        mac = d.get(position).mac;
        ieee = d.get(position).ieee;
        port = d.get(position).port;
        s = "01";
        Kuaiguanutil k = new Kuaiguanutil();
        k.cmd = cmd;
        k.ieee = ieee;
        k.port = port;
        k.status = s;
        k.mac = mac;
        j = JSON.toJSONString(k);
        if (m.flag3) {
            wsc.send(j);
        }
        d.get(position).status = "01";

    }*/



            }else if(isSwitchOn==1){
                Log.d("","2222222222222222");
  /*  wsc = m.c;
    if (d.size() != 0) {
        mac = d.get(position).mac;
        ieee = d.get(position).ieee;
        port = d.get(position).port;
        s = "02";
        Kuaiguanutil k = new Kuaiguanutil();
        k.cmd = cmd;
        k.ieee = ieee;
        k.port = port;
        k.status = s;
        k.mac = mac;
        j = JSON.toJSONString(k);
        if (m.flag3) {
            wsc.send(j);
        }
        d.get(position).status = "02";
    }
*/



            }else if(isSwitchOn==2){
                Log.d("111111111111111","11111111111111111");
   /*wsc = m.c;
    if (d.size() != 0) {
        mac = d.get(position).mac;
        ieee = d.get(position).ieee;
        port = d.get(position).port;
        s = "00";
        Kuaiguanutil k = new Kuaiguanutil();
        k.cmd = cmd;
        k.ieee = ieee;
        k.port = port;
        k.status = s;
        k.mac = mac;
        j = JSON.toJSONString(k);
        if (m.flag3) {
            wsc.send(j);
        }
        d.get(position).status = "00";
    }*/




            }
        }
    });










      /*  autoButton.setHydropowerListener(new AutoButton.HydropowerListener() {
            @Override
            public void hydropower(int y) {


                if (y == 0) {

                } else if (y == 1) {
                    wsc = m.c;
                    if (d.size() != 0) {
                        mac = d.get(position).mac;
                        ieee = d.get(position).ieee;
                        port = d.get(position).port;
                        s = "02";
                        Kuaiguanutil k = new Kuaiguanutil();
                        k.cmd = cmd;
                        k.ieee = ieee;
                        k.port = port;
                        k.status = s;
                        k.mac = mac;
                        j = JSON.toJSONString(k);
                        if (m.flag3) {
                            wsc.send(j);
                        }

                        d.get(position).status = "02";
                        if (m.hand != null) {
                            Message msg = new Message();
                            msg.what = 0;
                            msg.obj = cmd;
                            m.hand.sendMessage(msg);
                        }

                    }

                } else if (y == 2) {
                    wsc = m.c;
                    if (d.size() != 0) {
                        mac = d.get(position).mac;
                        ieee = d.get(position).ieee;
                        port = d.get(position).port;
                        s = "00";
                        Kuaiguanutil k = new Kuaiguanutil();
                        k.cmd = cmd;
                        k.ieee = ieee;
                        k.port = port;
                        k.status = s;
                        k.mac = mac;
                        j = JSON.toJSONString(k);
                        if (m.flag3) {
                            wsc.send(j);
                        }
                        d.get(position).status = "00";
                        if (m.hand != null) {
                            Message msg = new Message();
                            msg.what = 0;
                            msg.obj = cmd;
                            m.hand.sendMessage(msg);
                        }

                    }
                }
            }});*/

}

}
